import request from '@/utils/request'

//列表
export function getList(pageNo , size , tab) {
    return request(({
        url: '/post/list',
        method: 'GET',
        params: { pageNo: pageNo, size: size, tab: tab }
    })) 
}

//发布
export function post(topic) {
    return request({
        url: '/post/create',
        method: 'POST',
        data: topic
    })
}

//编辑帖子
export function update(topic) {
  return request({
      url: '/post/update',
      method: 'POST',
      data: topic
  })
}

//删除帖子
export function deleteTopic(id) {
  return request({
    url: `/post/delete/${id}`,
    method: 'DELETE'
  })
}

//帖子详情
export function getTopic(id) {
    return request({
      url: '/post',
      method: 'GET',
      params: {
        id: id
      }
    })
}

//获取详情页推荐
export function getRecommendTopics(id) {
  return request({
    url: '/post/recommend',
    method: 'GET',
    params: {
      topicId: id
    }
  })
}